<style>
    .warehouseAreaDialog{}
    .warehouseAreaDialog .el-form-item{width:100%;display:block;}
   
    .warehouseAreaDialog .el-form-item.b-attribute .el-form-item__content{width:-moz-calc(100% - 100px);width:-webkit-calc(100% - 100px);width:calc(100% - 100px);}

    .warehouseAreaDialog .el-form-item__content .el-checkbox + .el-checkbox{margin-left:0;}
    .warehouseAreaDialog .el-form-item__content .el-checkbox{margin-right:15px;}
</style>
<template>
    <div class="warehouse-area-page">
        <el-form :inline="true" :model="warehouseAreaForm" class="demo-form-inline" style="border-bottom:1px solid #ccc;">
            <el-form-item label="库房编码" class="selectMB10">
                <el-input size="mini" v-model="warehouseAreaForm.wareHouseCode" placeholder="请输入库房属性"></el-input>
            </el-form-item>
            <el-form-item label="库房名称" class="selectMB10">
                <el-input size="mini" v-model="warehouseAreaForm.wareHouseName" placeholder="请输入库房名称"></el-input>
            </el-form-item>
            <el-form-item label="库区编码" class="selectMB10">
                <el-input size="mini" v-model="warehouseAreaForm.code" placeholder="请输入库区编码"></el-input>
            </el-form-item>
            <el-form-item label="库区名称" class="selectMB10">
                <el-input size="mini" v-model="warehouseAreaForm.name" placeholder="请输入库区名称"></el-input>
            </el-form-item>
             <el-form-item label="当前状态" class="selectMB10" style="margin-right: 10px;">
                <el-select size="mini" clearable v-model="warehouseAreaForm.status" placeholder="请选择">
                    <el-option v-for="(status,index) in statusLists" :key="index" :label="status.lable" :value="status.value"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item class="selectMB10">
                <el-button class="bolder outsideBtnBS selectAll" :disabled="selectDisabled" size="mini" type="danger" @click="queryWarehouseArea()">查询</el-button>
            </el-form-item>
        </el-form>
        <!--表格-->
        <label class="default-label">库区明细列表：</label>
        <!--新增按钮-->
        <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="createNew()">新增</el-button>
        <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="importFile">导入</el-button>
        <el-table :data="warehouseAreaData" border style="width: 100%;" v-loading.body="loading" element-loading-text="拼命加载中">
            <el-table-column type="index" header-align="center" align="center" label="序"  width="40"></el-table-column>
            <el-table-column label="操作" header-align="center" align="center" width="110">
                <template scope="scope">
                    <div class="operationItem bolder" v-if="scope.row.status" @click="handleStatus(scope.$index,scope.row)">禁用</div>
                    <div class="operationItem bolder" v-else @click="handleStatus(scope.$index,scope.row)">启用</div> 
                    <div class="operationItem disabled bolder" v-if="scope.row.status">修改</div>
                    <div class="operationItem bolder" v-else @click="handleUpdate(scope.$index,scope.row)">修改</div>
                    <div class="operationItem bolder" @click="handleSee(scope.$index,scope.row)">查看</div>
                </template>
            </el-table-column>
            <el-table-column prop="statusName" label="状态" header-align="center" align="center" width="80" show-overflow-tooltip></el-table-column>
            <el-table-column prop="code" label="库区编码" header-align="center" width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="name" label="库区名称" header-align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="remark" label="库区描述" header-align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="wareHouseCode" label="库房编码" header-align="center" width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="wareHouseName" label="库房名称" header-align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="wareHouseRemark" label="库房描述" header-align="center" show-overflow-tooltip></el-table-column>
        </el-table>
        <!--分页-->
        <el-pagination v-if="isPaging" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageIndex"  :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :page-count="totalPage" :total="totalNumber"></el-pagination>
         <!--新建弹窗-->
        <el-dialog title="新增库区信息" :visible.sync="dialogForm1Visible" size="small" class="warehouseAreaDialog" :lock-scroll="false">
            <el-form :inline="true" :model="addWarehouseAreaForm" class="demo-form-inline" style="border-bottom:1px solid #ccc;" ref="addWarehouseAreaForm"> 
                <el-form-item label="库房编码"  prop="wareHouseCode"  :rules="[{ required: true, message: '库房编码不能为空'}]"  :label-width="labelWidth">
                    <el-select size="mini" v-model.trim="addWarehouseAreaForm.wareHouseCode" placeholder="请选择" @change="selectedWarehouseCode">
                        <el-option v-for="(wareHouseCode,index) in wareHouseMesgLists" :key="index" :label="wareHouseCode.code" :value="wareHouseCode.code"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="库房名称" :label-width="labelWidth">
                    <el-input  v-model.trim="addWarehouseAreaForm.wareHouseName" placeholder="请输入库房名称" disabled></el-input>
                </el-form-item>
                <el-form-item label="库房描述" :label-width="labelWidth">
                    <el-input  v-model="addWarehouseAreaForm.wareHouseRemark" placeholder="请输入库房描述" disabled></el-input>
                </el-form-item>
                <el-form-item label="库区编码" prop="code"  :rules="[{ required: true, message: '库区编码不能为空'},{ max: 20, message: '最多不可超过20字符'}]"  :label-width="labelWidth">
                    <el-input  v-model.trim="addWarehouseAreaForm.code" placeholder="请输入库区编码"></el-input>
                </el-form-item>
                <el-form-item label="库区名称" prop="name"  :rules="[{ required: true, message: '库区名称不能为空'},{ max: 200, message: '最多不可超过200字符'}]" :label-width="labelWidth">
                    <el-input  v-model.trim="addWarehouseAreaForm.name" placeholder="请输入库区名称"></el-input>
                </el-form-item>
                <el-form-item label="库区描述" :label-width="labelWidth">
                    <el-input  v-model="addWarehouseAreaForm.remark" placeholder="请输入库区描述"></el-input>
                </el-form-item>
                <el-form-item label="库区状态" :label-width="labelWidth">
                    <el-radio-group v-model="addWarehouseAreaForm.status">
                        <el-radio :label="true">启用</el-radio>
                        <el-radio :label="false">禁用</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="库区管理属性" :label-width="labelWidth">
                    <el-checkbox label="实行库位管理" v-model="addWarehouseAreaForm.warehouseManagement"></el-checkbox>
                    <el-checkbox label="与WMS集成" v-model="addWarehouseAreaForm.wmsIntegrate"></el-checkbox>
                    <el-checkbox label="VIP库区" v-model="addWarehouseAreaForm.vipStorageSection"></el-checkbox>
                </el-form-item>
                <el-form-item label="库区业务属性" :label-width="labelWidth" class="b-attribute">
                    <el-checkbox-group v-model="addWarehouseAreaForm.businessAttribute" @change="selectedWareHouseBA">
                        <el-checkbox v-for="(wareHouseBA,index) in wareHouseBALists" :key="wareHouseBA.code" :label="wareHouseBA.name"></el-checkbox>
                    </el-checkbox-group>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="handleAddSAE">确定并退出</el-button>
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="handleAddSure">确定</el-button>
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click=" handleAddCancelWhArea">取消</el-button>
            </div>
        </el-dialog>
        <!--修改弹窗-->
        <el-dialog title="修改库房库区属性" :visible.sync="dialogForm2Visible" size="small" class="warehouseAreaDialog" :lock-scroll="false">
            <el-form :inline="true" :model="updateWarehouseAreaForm" class="demo-form-inline" style="border-bottom:1px solid #ccc;" ref="updateWarehouseAreaForm">
                <el-form-item label="库房编码" prop="wareHouseCode"  :rules="[{ required: true, message: '库房编码不能为空'}]" :label-width="labelWidth">
                    <el-input  v-model.trim="updateWarehouseAreaForm.wareHouseCode" placeholder="请输入库房编码" disabled></el-input>
                </el-form-item>
                <el-form-item label="库房名称" :label-width="labelWidth">
                    <el-input  v-model.trim="updateWarehouseAreaForm.wareHouseName" placeholder="请输入库房名称" disabled></el-input>
                </el-form-item>
                <el-form-item label="库房描述" :label-width="labelWidth">
                    <el-input  v-model="updateWarehouseAreaForm.wareHouseRemark" placeholder="请输入库房描述" disabled></el-input>
                </el-form-item>
                <el-form-item label="库区编码" prop="code"  :rules="[{ required: true, message: '库区编码不能为空'},{ max: 20, message: '最多不可超过20字符'}]" :label-width="labelWidth">
                    <el-input  v-model.trim="updateWarehouseAreaForm.code" placeholder="请输入库区编码" disabled></el-input>
                </el-form-item>
                <el-form-item label="库区名称" prop="name"  :rules="[{ required: true, message: '库区名称不能为空'},{ max: 200, message: '最多不可超过200字符'}]" :label-width="labelWidth">
                    <el-input  v-model.trim="updateWarehouseAreaForm.name" placeholder="请输入库区名称"></el-input>
                </el-form-item>
                <el-form-item label="库区描述" :label-width="labelWidth">
                    <el-input  v-model="updateWarehouseAreaForm.remark" placeholder="请输入库区描述"></el-input>
                </el-form-item>
                <el-form-item label="库区状态" :label-width="labelWidth">
                    <el-radio-group v-model="updateWarehouseAreaForm.status">
                        <el-radio :label="true">启用</el-radio>
                        <el-radio :label="false">禁用</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="库区管理属性" :label-width="labelWidth">
                    <el-checkbox label="实行库位管理" v-model="updateWarehouseAreaForm.warehouseManagement"></el-checkbox>
                    <el-checkbox label="与WMS集成" v-model="updateWarehouseAreaForm.wmsIntegrate"></el-checkbox>
                    <el-checkbox label="VIP库区" v-model="updateWarehouseAreaForm.vipStorageSection"></el-checkbox>
                </el-form-item>
                <el-form-item label="库区业务属性" :label-width="labelWidth" class="b-attribute">
                    <el-checkbox-group v-model="updateWarehouseAreaForm.businessAttribute" @change="selectedWareHouseBA">
                        <el-checkbox v-for="(wareHouseBA,index) in wareHouseBALists" :key="wareHouseBA.code" :label="wareHouseBA.name"></el-checkbox>
                    </el-checkbox-group>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="handleUpdateSAE">确定并退出</el-button>
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="handleUpdateSure">确定</el-button>
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="handleUpdateCancelWhArea">取消</el-button>
            </div>
        </el-dialog>
        <!--查看弹窗-->
        <el-dialog title="查看库房库区属性" :visible.sync="dialogForm3Visible" size="small" class="warehouseAreaDialog" :lock-scroll="false">
            <el-form :inline="true" :model="seeWarehouseAreaForm" class="demo-form-inline" style="border-bottom:1px solid #ccc;" ref="seeWarehouseAreaForm">
                <el-form-item label="库房编码" :label-width="labelWidth">
                    <el-input  v-model="seeWarehouseAreaForm.wareHouseCode" placeholder="请输入库房编码" disabled></el-input>
                </el-form-item>
                <el-form-item label="库房名称" :label-width="labelWidth">
                    <el-input  v-model.trim="seeWarehouseAreaForm.wareHouseName" placeholder="请输入库房名称" disabled></el-input>
                </el-form-item>
                <el-form-item label="库房描述" :label-width="labelWidth">
                    <el-input  v-model="seeWarehouseAreaForm.wareHouseRemark" placeholder="请输入库房描述" disabled></el-input>
                </el-form-item>
                <el-form-item label="库区编码" :label-width="labelWidth">
                    <el-input  v-model.trim="seeWarehouseAreaForm.code" placeholder="请输入库区编码" disabled></el-input>
                </el-form-item>
                <el-form-item label="库区名称" :label-width="labelWidth">
                    <el-input  v-model.trim="seeWarehouseAreaForm.name" placeholder="请输入库区名称" disabled></el-input>
                </el-form-item>
                <el-form-item label="库区描述" :label-width="labelWidth">
                    <el-input  v-model="seeWarehouseAreaForm.remark" placeholder="请输入库区描述" disabled></el-input>
                </el-form-item>
                <el-form-item label="库区状态" :label-width="labelWidth">
                    <el-radio-group v-model="seeWarehouseAreaForm.status">
                        <el-radio :label="true" disabled>启用</el-radio>
                        <el-radio :label="false" disabled>禁用</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="库区管理属性" :label-width="labelWidth">
                    <el-checkbox label="实行库位管理" v-model="seeWarehouseAreaForm.warehouseManagement"></el-checkbox>
                    <el-checkbox label="与WMS集成" v-model="seeWarehouseAreaForm.wmsIntegrate"></el-checkbox>
                    <el-checkbox label="VIP库区" v-model="seeWarehouseAreaForm.vipStorageSection"></el-checkbox>
                </el-form-item>
                <el-form-item label="库区业务属性" :label-width="labelWidth" class="b-attribute">
                    <el-checkbox-group v-model="seeWarehouseAreaForm.businessAttribute">
                        <el-checkbox v-for="(wareHouseBA,index) in wareHouseBALists" :key="wareHouseBA.code" :label="wareHouseBA.name" disabled></el-checkbox>
                    </el-checkbox-group>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="dialogForm3Visible=false">确定</el-button>
            </div>
        </el-dialog>
        <!--导入弹框-->
        <el-dialog title="导入库区信息" id="importFile" :visible.sync="importFileVisible" size="tiny"  :lock-scroll="false">
            <el-upload class="upload-demo"  :action="action" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" :on-preview="handlePreview" :on-remove="handleRemove" :file-list="fileList" :before-upload="beforeAvatarUpload" :on-success="handleAvatarSuccess">
                <el-button size="mini" type="danger">点击上传</el-button>
                <div slot="tip" class="el-upload__tip">只能上传excel文件</div>
            </el-upload>
        </el-dialog>
    </div>
</template>
<script>
       export default {
        data() {
            return {
                // 查询表单
                warehouseAreaForm:{
                    wareHouseCode:"",
                    wareHouseName:"",
                    name:"",
                    code:"",
                    status:""
                },
                statusLists:[],   //当前状态下拉列表
                loading:false,
                disabled:false,
                warehouseAreaData:[],
                labelWidth:"100px",
                addWarehouseAreaForm:{
                    id:"",
                    wareHouseCode:"",
                    wareHouseName:"",
                    wareHouseRemark:"",
                    name:"",
                    code:"",
                    remark:"",
                    status:false,
                    warehouseManagement:false,
                    wmsIntegrate:false,
                    vipStorageSection:false,
                    businessAttribute:[]      // 库区业务属性
                },
                wareHouseMesgLists:[], // 新增弹窗库房信息下拉列表
                wareHouseBALists:[],   // 库区业务属性下拉列表
                addSureFlag:false,   // 新增的弹窗确定（不退出）
                updateWarehouseAreaForm:{
                    id:"",
                    wareHouseCode:"",
                    wareHouseName:"",
                    wareHouseRemark:"",
                    name:"",
                    code:"",
                    remark:"",
                    status:false,
                    warehouseManagement:false,
                    wmsIntegrate:false,
                    vipStorageSection:false,
                    businessAttribute:[]      // 库区业务属性
                },
                updateSureFlag:false,   // 修改的弹窗确定（不退出）
                seeWarehouseAreaForm:{
                    wareHouseCode:"",
                    wareHouseName:"",
                    wareHouseRemark:"",
                    name:"",
                    code:"",
                    remark:"",
                    status:false,
                    warehouseManagement:false,
                    wmsIntegrate:false,
                    vipStorageSection:false,
                    businessAttribute:[]      // 库区业务属性
                },


                //弹窗
                dialogForm1Visible:false,   // 新建
                dialogForm2Visible:false,   // 修改
                dialogForm3Visible:false,   // 查看
                // 分页
                isPaging:false,
                pageIndex:1,    //当前页（必传）
                pageSize :10,   //每页多少条
                totalNumber: 20,
                totalPage:2,
                
                //查询禁用
                selectDisabled:false,


                
                action:"",
                fileList: [],
                importFileVisible:false
            };
        },
       //进入页面立即运行此方法
       mounted: function () {
            var _this = this;
            _this.$store.commit('currentActive', 'WarehouseArea');
            // //ajax前后查询按钮禁用
            // $(".selectAll").ajaxStart(function(){
            //     _this.selectDisabled=true;
            // });
            // $(".selectAll").ajaxStop(function(){
            //     _this.selectDisabled=false;
            // });

            // 上传地址
            _this.action=_this.iwm_service+"storageSection/import";

            _this.dropDownValue();// 当前状态下拉列表
           _this.queryWarehouseArea();    //表单查询
            _this.wareHouseBADropDown();   // 库区业务属性下拉列表
       },
        methods:{
            // 当前状态下拉列表
            dropDownValue(){
                var _this=this;
                var tmp=["warehouseTag.warehouseTagStatus"];
                $.ajax({
                    type:'POST',
                    url:_this.iwm_service+'stock/getPullDownList',
                    cache:false,
                    data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType:"application/json;charset=utf-8",
                    success:function(data){
                        if(data.success){
                            _this.statusLists=data.data;
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            // 库区业务属性下拉列表
            wareHouseBADropDown(){
                var _this = this;
                $.ajax({
                    type:'GET',
                    url:_this.iwm_service+'StoreReserv/queryShuXing',
                    cache:false,
                    // data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType:"application/json;charset=utf-8",
                    success:function(data){
                        if(data.success){
                            _this.wareHouseBALists=data.data;
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            //查询库区属性列表
            queryWarehouseArea(){
                var _this=this;
                _this.loading=true;
                var tmp={
                    wareHouseName:_this.warehouseAreaForm.wareHouseName,
                    wareHouseCode:_this.warehouseAreaForm.wareHouseCode,
                    id:_this.warehouseAreaForm.id,
                    name:_this.warehouseAreaForm.name,
                    code:_this.warehouseAreaForm.code,
                    status:_this.warehouseAreaForm.status,
                    pageIndex:_this.pageIndex,
                    pageSize:_this.pageSize
                };
                _this.selectDisabled=true;
                $.ajax({
                    type: 'POST',
                    url: _this.iwm_service+"StoreReserv/queryPage",
                    cache: false,
                    data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType: "application/json;charset=utf-8",
                    success: function (data) {
                        if (data.success) {
                            _this.loading=false;
                            _this.isPaging=true;
                            _this.totalPage=data.data.totalPage;
                            _this.totalNumber=data.data.totalNumber;
                            _this.warehouseAreaData=data.data.dataList;
                        }else{
                            _this.common.errorTip(data.errorMessage)
                        }
                        _this.selectDisabled=false;
                    }
                });
            },
            //导入按钮
            importFile(){
                var _this=this;
                _this.importFileVisible = true;
                _this.fileList=[];

            },
             //上传文件之前的钩子
            beforeAvatarUpload(file) {
                // console.log(file);
                const isExcel2007 = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
                const isExcel2003 = file.type === 'application/vnd.ms-excel';
                if (!isExcel2007 && !isExcel2003) {
                    this.$message.error('只能上传excel文件!');
                }
                return isExcel2007 || isExcel2003 ;
            },
            // 文件上传成功时的钩子
            handleAvatarSuccess(res, file) {
                 var _this=this;
                if(res.success){
                    _this.common.successTip("上传成功！");
                    _this.importFileVisible = false;
                    //上传成功刷新页面
                    _this.queryWarehouseArea(_this.pageIndex,_this.pageSize);  
                }else{
                    _this.fileList=[];
                    _this.common.errorTip(res.errorMessage);
                }
                // console.log(res);
                // console.log(file);
            },
            handleRemove(file, fileList) {
                console.log(file, fileList);
            },
            handlePreview(file) {
                console.log(file);
            },
            //新增库区属性信息
            createNew(){
                var _this=this;
                _this.dialogForm1Visible=true; 
                if(this.$refs['addWarehouseAreaForm']) {
                    this.$refs['addWarehouseAreaForm'].resetFields();
                }
                _this.addWarehouseAreaForm.wareHouseName="";
                _this.addWarehouseAreaForm.wareHouseCode="";
                _this.addWarehouseAreaForm.wareHouseRemark="";
                _this.addWarehouseAreaForm.name="";
                _this.addWarehouseAreaForm.code="";
                _this.addWarehouseAreaForm.remark="";
                _this.addWarehouseAreaForm.status=false; 
                _this.addWarehouseAreaForm.warehouseManagement=false;   // 实行库位管理
                _this.addWarehouseAreaForm.wmsIntegrate=false;    // 与WMS集成
                _this.addWarehouseAreaForm.vipStorageSection=false;   // VIP库区
                _this.addWarehouseAreaForm.businessAttribute = [];   // 选中的库区业务属性清空
                _this.wareHouseMesgDropDown(); // 新增弹窗库房信息下拉列表 
            },
            // 新增弹窗库房信息下拉列表 
            wareHouseMesgDropDown(){
                var _this = this;
                $.ajax({
                    type:'GET',
                    url:_this.iwm_service+'StoreReserv/queryWareHouse',
                    cache:false,
                    // data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType:"application/json;charset=utf-8",
                    success:function(data){
                        if(data.success){
                            _this.wareHouseMesgLists=data.data;
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            // 新增弹窗的库房编码=====》库房名称及描述
            selectedWarehouseCode(){
                var _this = this;
                for(var i=0;i<_this.wareHouseMesgLists.length;i++){
                    if(_this.addWarehouseAreaForm.wareHouseCode == _this.wareHouseMesgLists[i].code){
                        _this.addWarehouseAreaForm.wareHouseName=_this.wareHouseMesgLists[i].name;
                        _this.addWarehouseAreaForm.wareHouseId=_this.wareHouseMesgLists[i].id;
                        _this.addWarehouseAreaForm.wareHouseRemark=_this.wareHouseMesgLists[i].remark;
                    }
                }
            },
            //新增弹窗中 选择库区业务属性
            selectedWareHouseBA(value){
                var _this = this;
                _this.seedWareHouseBA(value);
            },
            // 库区业务属性
            seedWareHouseBA(value){
                var _this = this;
                var businessAttributeValue=[],selectedValue=[];
                for(var i=0;i<value.length;i++){
                    for(var j=0;j<_this.wareHouseBALists.length;j++){
                        if(value[i] == _this.wareHouseBALists[j].name){
                            businessAttributeValue.push(_this.wareHouseBALists[j].id);
                        }
                    }
                }
                for(var k=0;k<businessAttributeValue.length;k++){
                    selectedValue.push({
                        businessAttributeId:businessAttributeValue[k]
                    });
                }
                if(_this.dialogForm1Visible){
                    _this.addWarehouseAreaForm.checkedBusinessAttribute = selectedValue;
                }else if(_this.dialogForm2Visible){
                    _this.updateWarehouseAreaForm.checkedBusinessAttribute = selectedValue;
                }
            },
            // 新增的确定并退出按钮
            handleAddSAE(){
                var _this = this;
                _this.addSureFlag = true;
                _this.handleAddSaveWhArea();
            },
            // 新增的确定按钮
            handleAddSure(){
                var _this = this;
                _this.addSureFlag = false;
                _this.handleAddSaveWhArea();
            },
            //新建保存
            handleAddSaveWhArea(){
                var _this=this;
                _this.$refs["addWarehouseAreaForm"].validate((valid) => {
                    if (valid) {
                        var tmp={
                            list:[
                                {
                                    wareHouseId:_this.addWarehouseAreaForm.wareHouseId, 
                                    wareHouseName:_this.addWarehouseAreaForm.wareHouseName,   
                                    wareHouseCode:_this.addWarehouseAreaForm.wareHouseCode,
                                    wareHouseRemark:_this.addWarehouseAreaForm.wareHouseRemark,
                                    name:_this.addWarehouseAreaForm.name,
                                    code:_this.addWarehouseAreaForm.code,
                                    remark:_this.addWarehouseAreaForm.remark,
                                    status:_this.addWarehouseAreaForm.status,
                                    warehouseManagement:_this.addWarehouseAreaForm.warehouseManagement,
                                    wmsIntegrate:_this.addWarehouseAreaForm.wmsIntegrate,
                                    vipStorageSection:_this.addWarehouseAreaForm.vipStorageSection,
                                    businessAttribute:_this.addWarehouseAreaForm.checkedBusinessAttribute
                                }
                            ]
                        };
                        $.ajax({
                            type: 'POST',
                            url: _this.iwm_service+"StoreReserv/add",
                            cache: false,
                            data:JSON.stringify(tmp),
                            dataType:'JSON',
                            contentType: "application/json;charset=utf-8",
                            success: function (data) {
                                if (data.success) {
                                    _this.common.successTip("保存成功！");
                                    if(_this.addSureFlag){
                                        _this.dialogForm1Visible=false;
                                    }
                                    _this.queryWarehouseArea();
                                }else{
                                    _this.common.errorTip(data.errorMessage);
                                }
                            }
                        });
                    } else {
                        _this.common.errorTip("存在未填写的必填项！");
                        return false;
                    }
                });
            },
            //新建取消
            handleAddCancelWhArea(){
                var _this=this;
                _this.dialogForm1Visible=false;
                if(this.$refs['addWarehouseAreaForm']) {
                    this.$refs['addWarehouseAreaForm'].resetFields();
                }
                _this.addWarehouseAreaForm.wareHouseName="";
                _this.addWarehouseAreaForm.wareHouseCode="";
                _this.addWarehouseAreaForm.wareHouseRemark="";
                _this.addWarehouseAreaForm.name="";
                _this.addWarehouseAreaForm.code="";
                _this.addWarehouseAreaForm.remark="";
                _this.addWarehouseAreaForm.status=false;
                _this.addWarehouseAreaForm.warehouseManagement=false;   // 实行库位管理
                _this.addWarehouseAreaForm.wmsIntegrate=false;    // 与WMS集成
                _this.addWarehouseAreaForm.vipStorageSection=false;   // VIP库区
                _this.addWarehouseAreaForm.businessAttribute = [];   // 选中的库区业务属性清空
            },
            // 操作启用禁用
            handleStatus(index, row){
                var _this=this;
                if(row.status){
                    row.status = false;
                }else{
                    row.status = true;
                }
                var tmp={id: row.id,status: row.status}; 
                $.ajax({
                    type: 'POST',
                    url: _this.iwm_service+"StoreReserv/updateStatus",
                    cache: false,
                    data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType: "application/json;charset=utf-8",
                    success: function (data) {
                        if (data.success) {
                            // 当前状态的显示
                            if(row.status){
                                row.statusName = "启用";
                                _this.common.successTip("启用成功！");
                            }else{
                                row.statusName = "禁用";
                                _this.common.successTip("禁用成功！");
                            }
                        }else
                            _this.common.errorTip(data.errorMessage);
                    }
                });
            },
            //点击修改
            handleUpdate(index,row){
                var _this=this;
                _this.dialogForm2Visible=true;
                _this.handleGetData(row.id);
            },
            // 修改的确定并退出按钮
            handleUpdateSAE(){
                var _this = this;
                _this.updateSureFlag = true;
                _this.handleSaveUpdateWhArea();
            },
            // 修改的确定按钮
            handleUpdateSure(){
                var _this = this;
                _this.updateSureFlag = false;
                _this.handleSaveUpdateWhArea();
            },
            //修改保存
            handleSaveUpdateWhArea(){
                var _this=this;
                _this.$refs["updateWarehouseAreaForm"].validate((valid) => {
                    if (valid) {
                        var tmp={
                            id:_this.updateWarehouseAreaForm.id,
                            wareHouseId:_this.updateWarehouseAreaForm.wareHouseId, 
                            wareHouseName:_this.updateWarehouseAreaForm.wareHouseName,
                            wareHouseCode:_this.updateWarehouseAreaForm.wareHouseCode,
                            wareHouseRemark:_this.updateWarehouseAreaForm.wareHouseRemark,
                            name:_this.updateWarehouseAreaForm.name,
                            code:_this.updateWarehouseAreaForm.code,
                            remark:_this.updateWarehouseAreaForm.remark,
                            status: _this.updateWarehouseAreaForm.status,
                            warehouseManagement:_this.updateWarehouseAreaForm.warehouseManagement,
                            wmsIntegrate:_this.updateWarehouseAreaForm.wmsIntegrate,
                            vipStorageSection:_this.updateWarehouseAreaForm.vipStorageSection,
                            businessAttribute:_this.updateWarehouseAreaForm.checkedBusinessAttribute
                            };
                        $.ajax({
                            type: 'POST',
                            url: _this.iwm_service+"StoreReserv/update",
                            cache: false,
                            data:JSON.stringify(tmp),
                            dataType:'JSON',
                            contentType: "application/json;charset=utf-8",
                            success: function (data) {
                                if (data.success) {
                                    _this.common.successTip("修改成功！");
                                    if(_this.updateSureFlag){
                                        _this.dialogForm2Visible=false;
                                    }
                                    _this.queryWarehouseArea();
                                }else
                                    _this.common.errorTip(data.errorMessage);
                            }
                        });
                    } else {
                        _this.common.errorTip("存在未填写的必填项！");
                        return false;
                    }
                });
            },
            //修改取消
            handleUpdateCancelWhArea(){
                var _this=this;
                _this.dialogForm2Visible=false;
            },
            // 点击查看
            handleSee(index,row){
                var _this=this;
                _this.dialogForm3Visible=true;
                _this.handleGetData(row.id);
            },
            // 修改查看取值
            handleGetData(id){
                var _this = this;
                $.ajax({
                    url:_this.iwm_service+'StoreReserv/queryStoreById?id='+id,
                    type:'GET',
                    cache:false,
                    // data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType:'application/json;charset=utf-8',
                    success:function(data){
                        if(data.success){
                            var bAArr = data.data.businessAttribute;
                            var tmpBA = [];
                            // 库区业务属性
                            for(var i=0;i<bAArr.length;i++){
                                tmpBA.push(bAArr[i].businessAttributeName);
                            }
                            if(_this.dialogForm2Visible){
                                _this.updateWarehouseAreaForm = data.data;
                                _this.updateWarehouseAreaForm.businessAttribute = tmpBA;
                                _this.seedWareHouseBA(tmpBA);   // 库区业务属性
                            }
                            if(_this.dialogForm3Visible){
                                _this.seeWarehouseAreaForm = data.data;
                                _this.seeWarehouseAreaForm.businessAttribute = tmpBA;
                            }
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })

            },
            //   分页
            handleSizeChange(val) {
                var _this=this;
                _this.pageSize=val;
                _this.queryWarehouseArea();

            },
            //点击页码分页查询点击事件
            handleCurrentChange(val) {
                var _this=this;
                _this.pageIndex=val;
                _this.queryWarehouseArea();
            }

        }
    }
</script>
